﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace BismillahReader.Core
{
    public class RecitationSource : INotifyPropertyChanged
    {
        private int _surahNo = 0;
        private int _ayatNo = 0;

        public int SurahNo 
        {
            get { return _surahNo; }
            set 
            { 
                _surahNo = value;
                RaiseChange();
            }
        }

        private const string URL_TEMPLATE = "http://www.everyayah.com/data/Alafasy_64kbps/{0}{1}.mp3";
        private const string FORMAT_TEMPLATE = "000";

        public int AyatNo
        {
            get { return _ayatNo; }
            set
            {
                _ayatNo = value;
                RaiseChange();
            }
        }

        public Uri Url
        {
            get { return new Uri(string.Format(URL_TEMPLATE, this.SurahNo.ToString(FORMAT_TEMPLATE), this.AyatNo.ToString(FORMAT_TEMPLATE))); }
        }

        #region INotifyPropertyChanged Members

        private void RaiseChange ()
        {
            if ( this.PropertyChanged!= null)
            {
                this.PropertyChanged (this, new PropertyChangedEventArgs ("Url"));
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion
    }
}
